//
//  Global.m
//  BaseLib
//
//  Created by CPX on 2018/5/21.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "Global.h"

/**
 全局常用计算Frame相关
 @author yzl
 */
@implementation Global

+ (UIColor*)defaultBackBtnColor{
    static UIColor *color = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        color = [UIColor blackColor];
    });
    return color;
}

+ (CGFloat)tabbarHeight{
    static CGFloat height = 49;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if(IS_iPhoneX){
            height = 49+34;
        }
    });
    return height;
}

+ (CGFloat)navHeight{
    static CGFloat height = 64;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        if(IS_iPhoneX){
            height = 88;
        }
    });
    return height;
}

+ (CGFloat)cellHeightForStandard:(CGFloat)height{
    CGSize size= [UIScreen mainScreen].bounds.size;
    if(size.width == 320){
        return size.height/667*height;
    }
    return height;
}

+ (CGFloat)heightScale{
    static float scale = 0;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        CGSize size= [UIScreen mainScreen].bounds.size;
        scale = size.height/667;
    });
    return scale;
}

+ (CGFloat)widthScale{
    static float scale = 0;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        CGSize size= [UIScreen mainScreen].bounds.size;
        scale = size.width/375;
    });
    return scale;
}

+ (BOOL) isIPhoneX
{
    
    if (@available(iOS 11.0, *)) {
        /// 利用safeAreaInsets.bottom > 0.0来判断是否是iPhone X。
        UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window];
        if (mainWindow.safeAreaInsets.bottom > 0.0) {
            return YES;
        }
    }
    return NO;
}


@end
